﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hopscotch.Presentation.Common.Converters;
using FluentAssertions;
using NUnit.Framework;
using System.Windows;

namespace Hopscotch.Presentation.Common.Test.Converters
{
    [TestFixture]
    public class BooleanToVisibilityConverterTest
    {
        private BooleanToVisibilityConverter booleanToVisibilityConverter;

        [SetUp]
        public void SetUp()
        {
            booleanToVisibilityConverter = new BooleanToVisibilityConverter();
        }

        [Test]
        public void TestDefaultTargetValues()
        {
            booleanToVisibilityConverter.TrueVisibility.Should().Be(Visibility.Visible);
            booleanToVisibilityConverter.FalseVisibility.Should().Be(Visibility.Collapsed);
        }

        [Test]
        public void TestConvertNullShouldBeNull()
        {
            booleanToVisibilityConverter.Convert(null, typeof(Visibility), null, null).Should().BeNull();
        }

        [Test]
        public void TestConvertBackNullShouldBeNull()
        {
            booleanToVisibilityConverter.ConvertBack(null, typeof(Visibility), null, null).Should().BeNull();
        }

        [TestCase(true, Visibility.Visible)]
        [TestCase(false, Visibility.Collapsed)]
        public void TestConvertedInputShouldBeExpected(bool input, Visibility expected)
        {
            booleanToVisibilityConverter.Convert(input, typeof(Visibility), null, null).Should().Be(expected);
        }

        [TestCase(false, Visibility.Visible)]
        [TestCase(true, Visibility.Collapsed)]
        public void TestConvertWithInvertedInputShouldBeExpected(bool input, Visibility expected)
        {
            booleanToVisibilityConverter.InvertInput = true;
            booleanToVisibilityConverter.Convert(input, typeof(Visibility), null, null).Should().Be(expected);
        }

        [TestCase(Visibility.Visible, true)]
        [TestCase(Visibility.Collapsed, false)]
        public void TestConvertBackInputShouldBeExpected(Visibility input, bool expected)
        {
            booleanToVisibilityConverter.ConvertBack(input, typeof(Visibility), null, null).Should().Be(expected);
        }

        [TestCase(Visibility.Visible, false)]
        [TestCase(Visibility.Collapsed, true)]
        public void TestConvertBackWithInvertedInputShouldBeExpected(Visibility input, bool expected)
        {
            booleanToVisibilityConverter.InvertInput = true;
            booleanToVisibilityConverter.ConvertBack(input, typeof(Visibility), null, null).Should().Be(expected);
        }
    }
}
